Prev | Current Page 785 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

tpl *}
{load_presentation_object filename="amazon_products_list" assign="obj"}

{$obj->mDepartmentName}


{$obj->mDepartmentDescription}




{section name=k loop=$obj->mProducts}
{if $smarty.section.k.index % 2 == 0}

{/if}

{if $smarty.section.k.index % 2 != 0 && !$smarty.section.k.first ||
$smarty.section.k.last}

{/if}
{/section}




{$obj->mProducts[k].item_name}



by {$obj->mProducts[k].brand}



{if $obj->mProducts[k].image neq ""}

alt="{$obj->mProducts[k].item_name}" width="120" />

{/if}



{if $obj->mProducts[k].price neq ""}
Price: {$obj->mProducts[k].price}
{/if}




CHAPTER 22 ?–  USING AMAZON.COM WEB SERVICES 682
Buy From Amazon



2. Create a new file named amazon_products_list.php in the presentation folder, and add the following
code in it:
// Class that handles receiving AWS data
class AmazonProductsList
{
// Public variables available in smarty template
public $mProducts;
public $mDepartmentName;
public $mDepartmentDescription;
// Constructor
public function __construct()
{
$this->mDepartmentName = AMAZON_DEPARTMENT_TITLE;
$this->mDepartmentDescription = AMAZON_DEPARTMENT_DESCRIPTION;
}
public function init()
{
$amazon = new Amazon();
$this->mProducts = $amazon->GetProducts();
for ($i = 0;$i < count($this->mProducts); $i++)
$this->mProducts[$i]['link_to_product'] =
'http://www.


Pages:
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
FIRMA trzpienie frezarskie ogłoszenia pozycjonowanie stron uwodzenie